﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Discover
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            webBrowserMain.Navigate("google.co.uk");
            textBoxURL.Text = "http://www.google.com";
        }

        private void buttonGO_Click(object sender, EventArgs e)
        {
            webBrowserMain.Navigate(textBoxURL.Text);         
        }

        private void buttonForward_Click(object sender, EventArgs e)
        {
            webBrowserMain.GoForward();
        }

        private void buttonBack_Click(object sender, EventArgs e)
        {
            webBrowserMain.GoBack();
        }

        private void buttonRefresh_Click(object sender, EventArgs e)
        {
            webBrowserMain.Refresh();
        }

        private void buttonStop_Click(object sender, EventArgs e)
        {
            webBrowserMain.Stop();
        }


        private void webBrowserMain_ProgressChanged_1(object sender, WebBrowserProgressChangedEventArgs e)
        {
            try
            {
                progressBar1.Maximum = (int)e.MaximumProgress;
                progressBar1.Value = ((int)e.CurrentProgress < 0 || (int)e.MaximumProgress < (int)e.CurrentProgress) ? (int)e.MaximumProgress : (int)e.CurrentProgress;
            }
            catch (Exception)
            {

                throw;
            }
        }

        private void textBoxURL_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode==Keys.Enter)
            {
                webBrowserMain.Navigate(textBoxURL.Text); 
            }
        }

    }
}
